package com.cat.twoPointerTechnique;

import java.util.List;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/adjacent-increasing-subarrays-detection-ii/description/
 * @create 2025/8/9 14:36
 * @since JDK17
 */

public class Solution29 {
    public int maxIncreasingSubarrays(List<Integer> nums) {
        int ans = 0, n = nums.size(), start, last, i, j = 1;
        while (j < n && nums.get(j - 1) < nums.get(j)) {    // 在外面预处理一段
            j++;
        }
        if (j == n) {
            return n / 2;
        }
        for (i = 0; i < n; ) {
            last = i;
            i = j++;
            while (j < n && nums.get(j - 1) < nums.get(j)) {
                j++;
            }
            ans = Math.max(ans, Math.max((i - last) / 2, Math.min(i - last, j - i)));
        }
        return ans;
    }
}
